package com.juyu.miliao.api.controller;

import com.juyu.miliao.api.domain.NewBieGuide;
import com.juyu.miliao.api.service.NewBieGuideService;
import com.juyu.miliao.api.service.UserWalletService;
import com.juyu.miliao.common.domain.Subject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.core.Authentication;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 新手指南和主播学堂
 * @Auther: 卜加超
 * @Date: 2019/5/21 10:28
 * @Description:
 */
@RestController
@RequestMapping("/newBieGuide")
public class NewBieGuideController {
    private static final Logger logger = LoggerFactory.getLogger(NewBieGuideController.class);
    @Resource
    private NewBieGuideService newBieGuideService;

    @GetMapping("/list")
    public List<NewBieGuide> getNewBieGuideList(@RequestParam(required = false) Integer type){
        if(StringUtils.isEmpty(type)){
            type = 0;
        }
        return newBieGuideService.getNewBieGuideList(type);
    }

    /**
     * 新手指南之游戏赠送1w寻豆
     * @param token
     */
    @PostMapping("/beans")
    public Map<String,Object> giveUserBeans(Authentication token){
      Subject subject = (Subject) token.getPrincipal();
      return newBieGuideService.giveUserBeans(subject.getId(),10000);
    }
}
